<template>
  <div class="sop-main">
    <div class="sop-header">
      <div class="header-left">
        <div class="head-title">
          SOP
        </div>
        <img class="divider" src="@/assets/images/divider.png" />
        <el-select v-model="value" filterable size="small">
          <el-option v-for="item in cities" :key="item.value" :label="item.label" :value="item.value" size="small">
            <div class="select-option-item">
              <span>{{ item.label }}</span>
              <i class="el-icon-circle-close icon-close" v-if="actived != item.value"></i>
            </div>
          </el-option>
          <div class="other-option">
            <a class="link">企业管理</a>
          </div>
        </el-select>
      </div>
      <div class="header-right">
        <el-button size="small" @click.stop="onNavigationTo('/hook/sop/daily')">
          数据统计
        </el-button>
        <el-button size="small" type="primary" plain>休眠设置</el-button>
      </div>
    </div>
    <div class="sop-wrap">
      <div class="sop-left">
        <div class="menu-list" v-for="(item, index) in menuList" :key="index">
          <div class="menu-item">{{ item.name }}</div>
          <div :class="['sub-menu-item', chid.type === menuType && 'active']" v-for="(chid, idx) in item.children"
            :key="`${index}-${idx}`" @click="onCheckMenu(chid.type)">
            <i :class="chid.icon" />
            <span>{{ chid.name }}</span>
          </div>
        </div>
      </div>
      <div class="sop-right">
        <div class="sop-tips" v-if="menuType === 'user' || menuType === 'tag' || menuType === 'group'">
          <el-alert type="warning" show-icon :closable="false">
            <div slot="title" style="font-size: 14px;line-height: 22px;color: rgba(0,0,0,.85);">
              设置完成后，请点击右上角“应用配置”按钮，才能生效；如需单个企微号配置或查看具体客户添加详情请前往 “<a style="color: #3070ff;">单号配置</a>”
            </div>
          </el-alert>
        </div>
        <SopTable v-if="menuType === 'sop'" />
        <SopUser v-if="menuType === 'user'" />
        <SopMode v-if="menuType === 'mode'" />
        <SopTag v-if="menuType === 'tag'" />
        <SopGroup v-if="menuType === 'group'" />
      </div>
    </div>
  </div>
</template>
<script>
import SopTable from './components/SopTable'
import SopUser from './components/SopUser'
import SopMode from './components/SopMode'
import SopTag from './components/SopTag'
import SopGroup from './components/SopGroup'
export default {
  data() {
    return {
      actived: 0,
      cities: [{
        value: '0',
        label: '志新'
      }, {
        value: '1',
        label: '锐行'
      }],
      menuType: 'sop',
      menuList: [
        {
          name: '手动创建',
          children: [
            { name: '标准SOP', type: 'sop', icon: 'el-icon-coin' },
          ]
        },
        {
          name: '自动创建',
          children: [
            { name: '新客户SOP', type: 'user', icon: 'el-icon-user' },
            { name: '标签SOP', type: 'tag', icon: 'el-icon-price-tag' },
            { name: '群SOP', type: 'group', icon: 'el-icon-user-solid' },
          ]
        },
        {
          name: '模板库',
          children: [
            { name: '管理SOP模版', type: 'mode', icon: 'el-icon-date' },
          ]
        }
      ]
    }
  },
  components: {
    SopTable,
    SopUser,
    SopMode,
    SopTag,
    SopGroup
  },
  methods: {
    onNavigationTo(path) {
      this.$router.push(path)
    },
    onCheckMenu(type) {
      this.menuType = type
    }
  },
}
</script>
<style lang="scss" scoped>
.sop-main {
  .sop-header {
    height: 46px;
    background: #fff;
    border-bottom: 1px solid #e9e9e9;
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;

    .header-left {
      display: flex;
      align-items: center;
      justify-content: flex-start;

      .head-title {
        font-size: 14px;
        line-height: 22px;
        height: 48px;
        background: #fff;
        font-weight: 700;
        border-bottom: 1px solid #e9e9e9;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 11;
        display: flex;
        align-items: center;
        justify-content: flex-start;
      }

      .divider {
        margin: 0 20px;
        width: 1px;
        height: 16px;
      }
    }
  }

  .sop-wrap {
    position: relative;
    height: calc(100vh - 106px);
    overflow: hidden;
    margin: 12px 0 0 12px;
    background: #eee;
    display: flex;

    .sop-left {
      width: 200px;
      height: 100%;
      background: #fff;
      border: 1px solid #e9e9e9;
      margin-right: 12px;
      padding: 12px;
      overflow-x: hidden;
      overflow-y: auto;

      .menu-list {
        .menu-item {
          font-size: 12px;
          font-weight: 400;
          color: rgba(0, 0, 0, .45);
          line-height: 20px;
          margin-bottom: 8px;
        }

        .sub-menu-item {
          height: 32px;
          font-size: 14px;
          font-weight: 400;
          color: rgba(0, 0, 0, .85);
          line-height: 22px;
          display: flex;
          align-items: center;
          margin-bottom: 4px;
          padding-left: 12px;
          cursor: pointer;
          transition: all .3s;

          span {
            margin-left: 12px;
          }

          &.active {
            background: #ebf2ff;
            border-radius: 2px;
            color: #3070ff;

            .icon {
              fill: #3070ff;
            }
          }

          &:hover {
            background: #ebf2ff;
            border-radius: 2px;
          }
        }
      }
    }

    .sop-right {
      flex: 1 1;
      .sop-tips {
        margin-bottom: 10px;
      }
    }
  }
}
</style>
<style scoped>
.el-scrollbar .select-option-item {
  height: 34px;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.el-scrollbar .select-option-item:hover .icon-close {
  display: block;
}

.el-scrollbar .select-option-item .icon-close {
  display: none;
}

.el-scrollbar .other-option {
  padding: 0 8px;
  color: #2f54eb;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e9e9e9;
}

.el-scrollbar .other-option>.link {
  font-size: 14px;
}
</style>